package com.s08.e01.model;

public abstract class User extends Object {

	private String name;
	private String surname;
	private Address address;
	private Product[] cart = new Product[10];

	public User(String name, String surname) {
		setSurname(surname);
		setName(name);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public void process() {

	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public Product[] getCart() {
		return cart;
	}

	public void setCart(Product[] cart) {
		this.cart = cart;
	}

	public String showProducts() {
		Product[] products = getCart();
		String result = "";

		for (Product product : products) {
			if (product != null)
				result += "Product: " + product.showPrice()
						+ System.getProperty("line.separator");
		}
		
//		if (result == null) {
//			return "";}
//		else{
//			return result;
//		}    ==== 
//		
//		return result == null ? "" : result;
		return result;
	}

	@Override
	public String toString() {
		return "User [name=" + name + ", surname=" + surname + ", address="
				+ address + "]";
	}

}
